package com.itheima_15;

import java.util.ArrayList;
import java.util.Collections;

public class PokerDemo {
    public static void main(String[] args) {
        ArrayList<String> array = new ArrayList<String>();

        // 定义花色
        String[] colors = {"♦️", "♣️", "♥️", "♠️"};
        // 定义数字
        String[] numbers = {"2", "3", "4", "5", "6" ,"7", "8", "9", "10", "J", "Q", "K", "A"};
        // 拼接
        for (String color : colors) {
            for (String number : numbers) {
                array.add(color + number);
            }
        }
        array.add("小王");
        array.add("大王");

        // 洗牌
        Collections.shuffle(array);

        // 创建玩家
        ArrayList<String> zsArray = new ArrayList<String>();
        ArrayList<String> lsArray = new ArrayList<String>();
        ArrayList<String> wwArray = new ArrayList<String>();
        ArrayList<String> dpArray = new ArrayList<String>();

        // 发牌
        for (int i = 0; i < array.size(); i++) {
            String s = array.get(i);

            if (i >= array.size() - 3) {
                dpArray.add(s);
            } else if (i % 3 == 0) {
                zsArray.add(s);
            } else if (i % 3 == 1) {
                lsArray.add(s);
            } else if (i % 3 == 2) {
                wwArray.add(s);
            }
        }

        // 看牌
        lookPoker("张三", zsArray);
        lookPoker("李四", lsArray);
        lookPoker("王武", wwArray);
        lookPoker("底牌", dpArray);
    }

    public static void lookPoker(String name, ArrayList<String> arrayList) {
        System.out.print(name + "的牌是：");
        for (String a : arrayList) {
            System.out.print(a + " ");
        }
        System.out.println();
    }
}
